﻿using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace CustomizeControl
{
    public partial class HolderMsg : UserControl
    {
        public HolderMsg()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 穴位名称
        /// </summary>
        [Browsable(true)]
        [Description("穴位名称")]
        [Category("外观")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string HolderName
        {
            get { return holder_name_label.Text; }
            set { holder_name_label.Text = value; }
        }

        /// <summary>
        /// 穴位名称的X轴向位置
        /// </summary>
        [Browsable(true)]
        [Description("穴位名称的X轴向位置")]
        [Category("外观")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public int HolderNameX
        {
            get { return holder_name_label.Location.X; }
            set { holder_name_label.Location = new Point(value,4); }
        }

        /// <summary>
        /// 穴位名称的字体大小
        /// </summary>
        [Browsable(true)]
        [Description("穴位名称的字体大小")]
        [Category("外观")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public float HolderNameFontSize
        {
            get { return holder_name_label.Font.Size; }
            set { holder_name_label.Font = new Font("微软雅黑", value, FontStyle.Bold, GraphicsUnit.Point, ((byte)(134))); }
        }

        /// <summary>
        /// 物料SN
        /// </summary>
        [Browsable(true)]
        [Description("物料SN")]
        [Category("外观")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string MaterialSN
        {
            get { return material_SN_label.Text; }
            set { material_SN_label.Text = value; }
        }

        /// <summary>
        /// 是否有料
        /// </summary>
        [Browsable(true)]
        [Description("是否有料")]
        [Category("外观")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string MaterialExist
        {
            get { return material_exist_label.Text; }
            set {

                switch (value)
                {
                    case "有料":
                        material_exist_label.BackColor = Constants.蓝色;
                        break;
                    case "无料":
                        material_exist_label.BackColor = Constants.灰色;
                        break;
                    default:
                        result_label.BackColor = Constants.灰色;
                        break;
                }
                material_exist_label.Text = value; 
            }
        }

        /// <summary>
        /// 测试时间
        /// </summary>
        [Browsable(true)]
        [Description("测试时间")]
        [Category("外观")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public float TestTime
        {
            get { return float.Parse(tt_label.Text.Replace("s","")); }
            set { tt_label.Text = $"{value}s"; }
        }

        /// <summary>
        /// 测试结果
        /// </summary>
        [Browsable(true)]
        [Description("测试结果")]
        [Category("外观")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string TestResult
        {
            get { return result_label.Text; }
            set {
                switch (value)
                {
                    case "PASS":
                        result_label.ForeColor = Constants.绿色;
                        roundPanel.BackColor = Constants.绿色;
                        result_label.Location = new Point(82, 93);
                        break;
                    case "FAIL":
                        result_label.ForeColor = Constants.红色;
                        roundPanel.BackColor = Constants.红色;
                        result_label.Location = new Point(82, 93);
                        break;
                    case "TESTING":
                        result_label.ForeColor = Constants.灰色;
                        roundPanel.BackColor = Constants.灰色;
                        result_label.Location = new Point(82, 93);
                        break;
                    case "RETESTING":
                        result_label.ForeColor = Constants.黄色;
                        roundPanel.BackColor = Constants.黄色;
                        result_label.Location = new Point(75, 93);
                        break;
                    default:
                        result_label.ForeColor = Constants.灰色;
                        roundPanel.BackColor = Constants.灰色;
                        result_label.Location = new Point(82, 93);
                        break;
                }
                result_label.Text = value;
            }
        }
    }
}
